using System;
using System.Collections.Generic;
using System.Text;

namespace GriffinNav.GPS
{
    public class Latitude
    {
        private decimal mCoordinate;
        private LatitudeDirection mDirection;
        private int mDegrees;
        private decimal mMinutes;

        internal Latitude(int degrees, decimal minutes, LatitudeDirection direction)
        {
            mDegrees = degrees;
            mMinutes = minutes;

            // check direction of travel
            if (direction == LatitudeDirection.S) // south
            {
                // convert to negative decimal coordinate
                mCoordinate = 0 - ((decimal)degrees + (minutes / 60M));
            }
            else // north
            {
                // convert to positive decimal coordinate
                mCoordinate = (decimal)degrees + (minutes / 60M);
            }

            mDirection = direction;
        }

        public decimal Coordinate
        {
            get
            {
                return mCoordinate;
            }
        }

        public LatitudeDirection Direction
        {
            get
            {
                return mDirection;
            }
        }

        public int Degrees
        {
            get
            {
                return mDegrees;
            }
        }

        public decimal Minutes
        {
            get
            {
                return mMinutes;
            }
        }

        internal void Update(int degrees, decimal minutes, LatitudeDirection direction)
        {
            mDegrees = degrees;
            mMinutes = minutes;

            // check direction of travel
            if (direction == LatitudeDirection.S) // south
            {
                // convert to negative decimal coordinate
                mCoordinate = 0 - ((decimal)degrees + (minutes / 60M));
            }
            else // north
            {
                // convert to positive decimal coordinate
                mCoordinate = (decimal)degrees + (minutes / 60M);
            }

            mDirection = direction;
        }
    }
}
